var Request = new Object(); 
Request = GetRequest(); 
var programName = Request["programName"];
var unitName = Request["unitName"];
var deviceType = Request["deviceType"];
if(typeof(programName) == "undefined" || programName == null || programName==""){
	programName = "";
}
if(typeof(unitName) == "undefined" || unitName == null || unitName == ""){
	unitName = "";
}
if(typeof(deviceType) == "undefined" || deviceType == null || deviceType == ""){
	deviceType = 0;
}
function GetRequest() {
	var url = location.search; //获取url中"?"符后的字串  
	var theRequest = new Object();  
	if (url.indexOf("?") != -1) {  
		var str = url.substr(1);  
		strs = str.split("&");  
		for(var i = 0; i < strs.length; i ++) {  
			theRequest[strs[i].split("=")[0]]=unescape(decodeURI(strs[i].split("=")[1]));  
		}  
	}  
	return theRequest;  
}

function formatTime(str){
	var h = parseInt(str/(60*60));
	var m = parseInt((str%(60*60))/60);
	var s = parseInt(str%(60));
	return (h>=10?h:"0"+h)+":"+(m>=10?m:"0"+m)+":"+(s>=10?s:"0"+s);
}
var _noSessionDialog=undefined;
var _noRequiredDialog=undefined;
var _haveRequiredDialog=undefined;
$(document).ajaxComplete(function(event, xhr, settings) {
    //从http头信息取出 在filter定义的sessionstatus，判断是否是 timeout
    if(xhr.getResponseHeader("sessionstatus")=="timeout"){ //session超时，或失效
        if(xhr.getResponseHeader("loginPath")){
        	if(_noSessionDialog==undefined){
        		_noSessionDialog = dialog({
        			title: "系统消息",
        			width: '430px',
        			zIndex:99999999,
        			cancel:false,
        			content: "您还未登录或您已经超过15分钟没有进行操作，登录信息已经失效，请重新登录。",
        			okValue: "重新登录",
        			ok: function () {
        				window.parent.location.href="/";
        				return true;},
        			onclose: function () {
        				window.parent.location.href="/";
        			}
        		});
        		_noSessionDialog.showModal();
        	} 
        }
    }else if(xhr.getResponseHeader("sessionstatus")=="noRequiredInfo"){//没有完善必填信息而去访问别的页面
    	if(xhr.getResponseHeader("loginPath")){
        	if(_noRequiredDialog==undefined){
        		_noRequiredDialog = dialog({
        			title: "系统消息",
        			width: '430px',
        			zIndex:99999999,
        			cancel:false,
        			content: "您的必填信息还未填写完整，请先完善必填信息！",
        			okValue: "确认",
        			ok: function () {
        				window.location.href="/student/RequiredInfo.html";
        				return true;},
        			onclose: function () {
        				window.location.href="/student/RequiredInfo.html";
        			}
        		});
        		_noRequiredDialog.showModal();
        	} 
        }
    }else if(xhr.getResponseHeader("sessionstatus")=="haveRequiredInfo"){//完善了必填信息后再次访问必填信息页面
    	if(xhr.getResponseHeader("loginPath")){
        	if(_haveRequiredDialog==undefined){
        		_haveRequiredDialog = dialog({
        			title: "系统消息",
        			width: '430px',
        			zIndex:99999999,
        			cancel:false,
        			content: "您的必填信息已经填写过了，不能再次访问该页面！",
        			okValue: "确认",
        			ok: function () {
        				window.location.href="/student/MyInfo.html";
        				return true;},
        			onclose: function () {
        				window.location.href="/student/MyInfo.html";
        			}
        		});
        		_haveRequiredDialog.showModal();
        	} 
        }
    }
});

String.prototype.trim = function () {
	var str = this;
	str = str.replace(/^\s /, '' );
	for ( var i = str.length - 1; i >= 0; i--) {
		if (/\S/.test(str.charAt(i))) {
			str = str.substring(0, i+1);
			break ;
		}
	}
	return str;
};

Date.prototype.Format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};

window.alert=function(str){
	var d = dialog({
		title: "提示",
		content:str,
		zIndex:99999,
		okValue:"确定",
		ok:function(){return true;}
	});
	d.showModal();
};
window.document.oncontextmenu=function(){
	return false;
};